#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node{
    int di,vi,ai;
}a[100010];
int t,n,m,l,v;
int b[100010];
void work(){
    int last=0,ans=0,f=0,f1=0;
    cin>>n>>m>>l>>v;
    for(int i=1;i<=n;i++){
        cin>>a[i].di>>a[i].vi>>a[i].ai;
        if(a[i].ai!=0) f=1;
        if(a[i].ai<=0) f1=1;
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
        last=max(last,b[i]);
    }
    if(!f){
        for(int i=1;i<=n;i++)
            if(a[i].di<=last&&a[i].vi>v) ans++;
        if(ans>0) cout<<ans<<' '<<m-1<<'\n';
        else cout<<ans<<' '<<m<<'\n';
        return;
    }
    if(!f1){
        for(int i=1;i<=n;i++){
            int s=last-a[i].di;
            if(a[i].di<=last&&a[i].vi*a[i].vi+2*a[i].ai*s>v*v) ans++;
        }
        if(ans>0) cout<<ans<<' '<<m-1<<'\n';
        else cout<<ans<<' '<<m<<'\n';
        return;
    }
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>t;
    while(t--){
        work();
    }
    return 0;
}
